package com.example.stock.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.stock.entity.Stock;
import com.example.stock.mapper.StockMapper;
import com.example.stock.service.IStockService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 股票 服务实现类
 * </p>
 *
 * @author tanlvxu
 * @since 2024-12-18
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements IStockService {

    @Override
    public List<Stock> listByCalcTimeAndCalcType(String date, int i) {
        return this.list(Wrappers.<Stock>lambdaQuery().eq(Stock::getCalcTime, date).eq(Stock::getCalcType, i).gt(Stock::getHighLimit,0));
    }

    @Override
    public Stock getByCodeAndCalcTimeAndCalcType(String code, String nextGzr, int i) {
        return this.getOne(Wrappers.<Stock>lambdaQuery()
                        .eq(Stock::getCode,code)
                .eq(Stock::getCalcTime, nextGzr).eq(Stock::getCalcType, i).gt(Stock::getHighLimit,0));
    }

    @Override
    public List<Stock> calcYangDingTian(String day1,String day2,String day3) {
        return this.getBaseMapper().calcYangDingTian(day1,day2,day3);
    }

    @Override
    public List<Stock> maxStock(String code, String day1, String day2) {
        return this.getBaseMapper().maxStock(code,day1,day2);
    }

    @Override
    public List<Stock> calcStock(String day1, String day2, String day3) {
        return this.getBaseMapper().calcStock(day1,day2,day3);
    }
}
